﻿//https://leetcode.cn/problems/RQku0D/

class Solution {
public:
    bool checkvalidPalindrome(string& s, int left, int right)
    {
        while (left < right)
        {
            if (s[left] != s[right])
            {
                return false;
            }
            left++;
            right--;
        }

        return true;
    }
    bool validPalindrome(string s)
    {
        int n = s.size();
        int left = 0, right = n - 1;

        while (left < right)
        {
            if (s[left] == s[right])
            {
                left++;
                right--;
            }
            else
            {
                return checkvalidPalindrome(s, left + 1, right) || checkvalidPalindrome(s, left, right - 1);
            }
        }

        return true;

    }
};